package com.cc.noself.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cc.noself.dao.NoSelfBusDao;
import com.cc.noself.model.raw.NoSelfBus;


@Service(value = "com.cc.noself.service.NoSelfBusService")
public class NoSelfBusService {
	@Autowired
	private NoSelfBusDao aNoSelfBusDao;

	/**
	 * 根据组织查询列表
	 * @param ono 组织代码
	 * @return List<NoSelfBus>
	 */
	public List<NoSelfBus> getNoSelfBusList(String ono) {
		Map<String, Object> p = new HashMap<String, Object>();
		p.put("ono", ono);

		List<NoSelfBus> list = aNoSelfBusDao.getNoSelfBusList(p);

		return list;
	}

	/**
	 * 获取实体
	 * @param id 主键
	 * @return NoSelfBus
	 */
	public NoSelfBus getNoSelfBus(int id) {
		Map<String, Object> p = new HashMap<String, Object>();
		p.put("id", id);
		List<NoSelfBus> l = aNoSelfBusDao.getNoSelfBusList(p);
		return l.size() > 0 ? l.get(0) : null;
	}

	/**
	 * 创建实体
	 * @param NoSelfBus 实体信息
	 * @return NoSelfBus 实体信息
	 */
	public NoSelfBus createNoSelfBus(NoSelfBus entity) {
		aNoSelfBusDao.createNoSelfBus(entity);
		return entity;
	}
	
	/**
	 * 修改实体
	 * @param NoSelfBus 实体信息
	 * @return NoSelfBus 实体信息
	 */
	public NoSelfBus updateNoSelfBus(NoSelfBus entity) {
		aNoSelfBusDao.updateNoSelfBus(entity);
		return entity;
	}
	
	/**
	 * 删除实体
	 * @param NoSelfBus 实体信息
	 * @return NoSelfBus 实体信息
	 */
	public NoSelfBus deleteNoSelfBus(NoSelfBus entity) {
		deleteNoSelfBus(entity.getId());
		return entity;
	}
	
	/**
	 * 删除实体
	 * @param id 主键
	 * @return id 主键
	 */
	public int deleteNoSelfBus(int id) {
		aNoSelfBusDao.deleteNoSelfBus(id);
		return id;
	}

}

